import axios from 'axios'
import QS from "qs"
axios.defaults.withCredentials = true
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
axios.defaults.headers.post['Access-Control-Allow-Origin'] = 'http://localhost:8080'
axios.defaults.headers.post['Access-Control-Allow-Credentials'] = true
/* axios.header('Access-Control-Allow-Origin', 'http://localhost:8080')
axios.header('Access-Control-Allow-Credentials', 'true') */
/*商品列表*/
export function getList() {
    const  url='api/getList'
    const data = {
        pageNum:1,
        pageSize:10,
        orderBy:'default',
        categoryId:100012,
    }
    return axios.get(url,{
        params:data
    }).then((res)=>{
        return Promise.resolve(res.data)
    })

}
export function getProd(){
  const url = 'http://test.happymmall.com/product/list.do'
  const data = {
      pageNum:1,
      pageSize:10,
      orderBy:'default',
      categoryId:100012,
  }
  return axios.get(url,{
      params:data
  }).then((res)=>{
      return Promise.resolve(res.data)
  })
}


/*登录postLogin*/

export function postLogin(data) {
    const  url='api/postLogin'

    return axios.post(url,QS.stringify(data)).then((res)=>{
        return Promise.resolve(res.data)
    })

}
